using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;

namespace Accountability4net
{
    /// <summary>
    /// Defines a list of actions to be taken together.
    /// Implementors must secure that either all or none of the actions are completed
    /// when the transaction is commited with method <see cref="Commit()" />
    /// </summary>
    public interface ITransaction: IList<IAction>, INotifyPropertyChanged
    {
        /// <summary>
        /// Commits all actions in the transaction.
        /// </summary>
        /// <exception cref="UnbalancedTransactionException">
        /// This exception occurs if the sum of amount for <see cref="IAction">actions</see> of type <see cref="ActionType.DEBIT" />
        /// is not equal to the sum of amount for <see cref="IAction">actions</see> of type <see cref="ActionType.CREDIT" />
        /// when a <see cref="ITransaction">transaction</see> is <see cref="ITransaction.Commit()">committed</see>.
        /// </exception>
        void Commit();

        /// <summary>
        /// A unique identifier for the transaction
        /// </summary>
        Guid ID { get; set; }

        /// <summary>
        /// Indicates when the real-life transaction occured. This time is always in the past
        /// it is not possible to record future actions.
        /// </summary>
        DateTimeOffset Timestamp { get; set; }

        /// <summary>
        /// Description of the transaction.
        /// </summary>
        string Description { get; set;}

        /// <summary>
        /// Is <code>true</code> if the transaction has been successfully commited.
        /// </summary>
        bool IsCommitted { get;}
    }
}
